/// 指令类型
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Kind {
    /// 注册设备ID
    GetId = 0x11,
    /// 设备上线
    Login = 0x12,
    /// 心跳
    Heart = 0x13,
    /// 获取时间戳
    GetTimestamp = 0x14,
    /// 设置云端变量实际值
    SetActual = 0x21,
    /// 读取云端变量实际值
    GetActual = 0x22,
    /// 订阅云端变量实际值变更通知
    SubActual = 0x23,
    /// 订阅全部云端变量实际值变更通知
    SubAllActual = 0x25,
    /// 发送云端变量实际值变更通知
    NoticeActual = 0x27,
    /// 设置云端变量目标值
    SetTarget = 0x29,
    /// 读取云端变量目标值
    GetTarget = 0x2A,
    /// 订阅云端变量目标值变更通知
    SubTarget = 0x2B,
    /// 读取全部云端变量目标值
    SubAllTarget = 0x2D,
    /// 发送云端变量目标值变更通知
    NoticeTarget = 0x2F,
    /// 进入绑定模式
    EnterBind = 0x31,
    /// 用户绑定设备
    Bind = 0x32,
    /// 用户解绑设备
    Unbind = 0x33,
    /// 发送设备被绑定通知
    NoticeBind = 0x36,
    /// 发送设备被解绑通知
    NoticeUnbind = 0x37,
    /// 获取软件包最新版本
    GetOTAInfo = 0x41,
    /// 进入升级模式
    EnterOTA = 0x42,
    /// 退出升级模式
    ExitOTA = 0x43,
    /// 获取软件包分片
    GetOTA = 0x44,
    /// 无效状态
    Unknown,
}
impl Default for Kind {
    fn default() -> Self {
        Kind::Unknown
    }
}
impl From<u8> for Kind {
    fn from(kind: u8) -> Self {
        match kind {
            x if x == Kind::GetId as u8 => Kind::GetId,
            x if x == Kind::Login as u8 => Kind::Login,
            x if x == Kind::Heart as u8 => Kind::Heart,
            x if x == Kind::GetTimestamp as u8 => Kind::GetTimestamp,
            x if x == Kind::SetActual as u8 => Kind::SetActual,
            x if x == Kind::GetActual as u8 => Kind::GetActual,
            x if x == Kind::SubActual as u8 => Kind::SubActual,
            x if x == Kind::SubAllActual as u8 => Kind::SubAllActual,
            x if x == Kind::NoticeActual as u8 => Kind::NoticeActual,
            x if x == Kind::SetTarget as u8 => Kind::SetTarget,
            x if x == Kind::GetTarget as u8 => Kind::GetTarget,
            x if x == Kind::SubTarget as u8 => Kind::SubTarget,
            x if x == Kind::SubAllTarget as u8 => Kind::SubAllTarget,
            x if x == Kind::NoticeTarget as u8 => Kind::NoticeTarget,
            x if x == Kind::EnterBind as u8 => Kind::EnterBind,
            x if x == Kind::Bind as u8 => Kind::Bind,
            x if x == Kind::Unbind as u8 => Kind::Unbind,
            x if x == Kind::NoticeBind as u8 => Kind::NoticeBind,
            x if x == Kind::NoticeUnbind as u8 => Kind::NoticeUnbind,
            x if x == Kind::GetOTAInfo as u8 => Kind::GetOTAInfo,
            x if x == Kind::EnterOTA as u8 => Kind::EnterOTA,
            x if x == Kind::ExitOTA as u8 => Kind::ExitOTA,
            x if x == Kind::GetOTA as u8 => Kind::GetOTA,
            _ => Kind::Unknown,
        }
    }
}
